const webpack = require("webpack");
const path = require('path');

module.exports = {
  mode: 'development',
  entry: {
    first: path.resolve(__dirname, 'src/commons/first.js'),
    second: path.resolve(__dirname, 'src/commons/second.js'),
  },
  optimization: {
    splitChunks: {
      chunks: 'initial', // 只对入口文件处理
      cacheGroups: {
        commons: { // split `common`和`components`目录下被打包的代码到`page/commons.js && .css`
            test: /commons/,
            name: 'page/commons',
            priority: 10,
            enforce: true
        }
      }
    }
  }
};